// 1翻转字符串
let str = 'abcdef123'
let reverseStr = str.split('').reverse().join('')
console.log(reverseStr) //321fedcba

// 2找到提供的句子中最长的单词，并计算它的长度。
let str = "The quick brown fox jumped over the lazy dog"
function findLongestWord(str) {
    let obj = {}
    let arr = str.split(' ')
    let maxStr = arr[0]
    arr.forEach(element => element.length > maxStr.length ? maxStr = element : null)
    obj[maxStr] = maxStr.length
    return obj

}
let res = findLongestWord(str)
console.log(res)


// 确保字符串的每个单词首字母都大写，其余部分小写。
let str="The quick brown fox jumped over the lazy dog"
function titleCase(str){
    let arr=str.toLowerCase().split(' ')
    let res=arr.map(element=>element.charAt(0).toUpperCase()+element.substring(1))
    return res.join(' ')
}
let titleCaseStr=titleCase(str)
console.log(titleCaseStr) //The Quick Brown Fox Jumped Over The Lazy Dog